package com.aistar.service.user.impl;

import com.aistar.mapper.EmployeeMapper;
import com.aistar.mapper.ResumeMapper;
import com.aistar.model.dto.user.ResumeDTO;
import com.aistar.model.entity.Resume;
import com.aistar.service.user.IResumeCenterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class ResumeCenterServiceImpl implements IResumeCenterService {
    @Autowired
    private ResumeMapper resumeMapper;
    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public List<ResumeDTO> myResume(Integer employeeId) {
        List<ResumeDTO> lists = new ArrayList<>();
        int count =1;
        for (Resume resume:resumeMapper.findByEmployeeId(employeeId)){
            ResumeDTO resumeDTO = new ResumeDTO();
            String privacy = null;
            if (1 == resume.getPrivacy())
                privacy = "公开简历";
            if (0 == resume.getPrivacy())
                privacy = "私密简历";

            resumeDTO.setResume(resume);
            resumeDTO.setPrivacy1(privacy);
            resumeDTO.setCount(count++);
            lists.add(resumeDTO);
        }
        return lists;
    }
}
